<template>
  <div>
    <BreakSpace label="基本信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel
      ref="baseInfo"
      :list="initFormBase"
      :cols="3"
      :labelWidth="140"
      :isSubmitBtn="false"
      formType="show"
      @formChange="formChangeHandleBase"
    />
    <BreakSpace label="授权信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel
      ref="empowerInfo"
      :list="initFormEmpower"
      :cols="3"
      :labelWidth="140"
      :isSubmitBtn="false"
      formType="show"
      @formChange="formChangeHandleEmpower"
    />
    <BreakSpace label="建设节点信息" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel
      ref="buildInfo"
      :list="initFormBuild"
      :cols="3"
      :labelWidth="140"
      :isSubmitBtn="false"
      formType="show"
      @formChange="formChangeHandleBuild"
    />
    <BreakSpace label="进度节点信息" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      height='300'
      ref="progressTable"
      :columns="progressColumns"
      :dataSource="progressDataSource"
      :isColumnFilter="false"
      :isSelectColumn="isSelectColumn"
      :datakey="'dealerName'"
      :isToperInfo="false"
      columnsRef='origin_construct_inquire_addDialog_01'
      :onColumnsChange="columns => this.columns = columns"
    >
    </FilterTable>
    <BreakSpace label="订购节点信息" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      height='300'
      ref="orderTable"
      :columns="orderColumns"
      :dataSource="orderDataSource"
      :isColumnFilter="false"
      :isSelectColumn="isSelectColumn"
      :datakey="'dealerName'"
      :isToperInfo="false"
      columnsRef='origin_construct_inquire_addDialog_02'
      :onColumnsChange="columns => this.columns = columns"
    >
    </FilterTable>
    <BreakSpace label="总部反馈说明" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      height='100'
      ref="feedbackTable"
      :columns="feedbackColumns"
      :dataSource="feedbackDataSource"
      :isColumnFilter="false"
      :isSelectColumn="isSelectColumn"
      :datakey="'dealerName'"
      :isToperInfo="false"
      columnsRef='origin_construct_inquire_addDialog_03'
      :onColumnsChange="columns => this.columns = columns"
    >
    <template slot="controls">
        <el-button size="small" type="primary" icon="el-icon-plus" @click="openFeed">查看全部反馈说明</el-button>
      </template>
    </FilterTable>
    <BreakSpace label="施工进度说明" :containerStyle="{ marginBottom: '10px' }" />
    <FilterTable
      height='300'
      ref="photoTable"
      :columns="photoColumns"
      :fetchapi="fetchApiPhoto"
      :isColumnFilter="false"
      :isSelectColumn="isSelectColumn"
      :datakey="'records'"
      :params="fetchParams" 
      :isToperInfo="false"
      columnsRef='origin_construct_inquire_addDialog_04'
      :onColumnsChange="columns => this.columns = columns"
    >
    </FilterTable>
    <BreakSpace label="其他施工附件" :containerStyle="{ marginBottom: '10px' }" />
    <FormPanel
      ref="fileInfo"
      :list="initFormFile"
      :cols="1"
      :labelWidth="140"
      :isSubmitBtn="false"
      formType="show"
      @formChange="formChangeHandleFile"
    />
    <!-- 总部反馈信息弹窗信息弹窗 -->
    <BaseDialog 
      title="总部反馈" 
      width="700px"
      destroyOnClose
      :visible.sync="visibleFeed"
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}" >
      <feed-madal v-model="initDataFeed"  ref="projectDialog" @close="closeFeed" />
    </BaseDialog>
    
    <div class="dialogBottmView">
      <el-button  @click="closeDialog">关闭</el-button>
    </div>
  </div>
</template>
<script>
import feedMadal from './oemFeedback'
import { dictionary } from '@/utils/dictMixin';
import { getDealerApply,searchDealerApplyPnode ,searchDealerApplyOnode,searchDealerApplyOemFeedback,searchDealerApplyDealerFeedback,insertOtherPhoto,searchOtherPhoto} from '@/api/cms-api/origin/construct/dealer';
import { getRegion, getCommunity } from '@/api/cms-common/dealerdata/index';
import { region } from '@/api/cms-common/region';
import * as types from '@/api/cms-api/origin/construct/dealer/types';
import { parseTime } from '@/utils/index';
import { isArcfox } from '@/api/cms-api/origin/commonDealerType';		//渠道类型工具类
import { formatdateByDay } from '@/utils';

export default {
  components: {
    feedMadal
  },
  mixins: [dictionary,region],
  props: {
    value:{
        type: Object,
        default: null
    }
  },
  data() {
    return {
      applyId:"",  //经销商申请ID，进入赋值
      formData:[],
      dealerList:[],
      productList:[],
      dataSource:[],
      progressDataSource:[],
      orderDataSource:[],
      feedbackDataSource:[],
      photoDataSource:[],
      fetchParams:{"applyId":this.value.rowData.applyId,'check':'check'},  //施工进度列表查询参数
      visibleFeed:false,
      isSelectColumn: false,
      initFormBase: this.initFormBaseFun(),     //基本信息-初始化控件
      initFormEmpower: this.initFormEmpowerFun(), //授权信息-初始化控件
      initFormBuild: this.initFormBuildFun(),   //建设节点信息-初始化控件
      progressColumns: this.creatHeaderProgress(),  //进度节点信息-初始化表格头
      orderColumns: this.creatHeaderOrder(),    //订购节点信息-初始化表格头
      feedbackColumns: this.creatHeaderFeedback(),  //总部回馈-初始化表格头
      photoColumns: this.creatHeaderPhoto(),  //施工进度说明-初始化表格头
      initFormFile: this.initFormFileFun(),   //其他施工照片-初始化控件
      initDataFeed:{},  //总部反馈列表弹窗传递参数
      cityData: {},
      fetchApiPhoto: searchDealerApplyDealerFeedback
    };
  },
  mounted() {
    
    this.init();
  },
  computed: {
    
  },
  created() {
    //初始化事业部下拉数据
    this.getDeptData();

    //初始化省份信息
    this.initProvince();
  },
  methods: {
    //修改时，初始化页面数据
    async init(){
      // 更新接口需要的记录 ID
      this.applyId = this.value.rowData.applyId;  //赋值入网申请ID
      // this.initFormBase[0].initialValue=this.value.rowData.brandId; //赋值品牌
      
      //初始化所在市，区
      if(this.value.rowData['provinceId']){
        this.initCity(this.value.rowData['provinceId'],false);
      }
      if(this.value.rowData['cityId']){
        this.initTown(this.value.rowData['cityId'],false);
      }

      //初始化办事处
      if(this.value.rowData['deptId']){
        this.changeDeptSelect(this.value.rowData['deptId'],false);
      }

      //初始化渠道类型
      if(this.value.rowData['dealerType']){
        this.changeDealerType(this.value.rowData['dealerType'],false);
      }

      //循环为表单赋值
      //基本信息
      this.initFormBase.forEach(x => {
        if(x.fieldName === 'ownBrandCode'){
          if(this.value.rowData[x.fieldName]){
            let list = this.value.rowData[x.fieldName].split(',');
            x.initialValue  = list.map(x => parseInt(x));
          }else{
            x.initialValue  = [];
          }
        }else if(x.fieldName === 'createdAt'){
          if(this.value.rowData[x.fieldName]){
             x.initialValue = formatdateByDay(this.value.rowData[x.fieldName]);
          }
        }else{
          x.initialValue = this.value.rowData[x.fieldName];
        }
        if(x.fieldName=='appId'){
            //判断品牌，如果为ARCFOX时，细分类别显示且必填,渠道类型中，包含直营店、非直营店
            if(isArcfox()){
              // this.initFormBase[5].disabled = true;
              // this.initFormBase[5].rules = this.initFormBase[5].rulesTmp;
              this.dealerTypeRemove = ['25381006'];
            }else{
              this.dealerTypeRemove = ['25381004','25381005','25381006'];//2538
            }
            this.initFormBase[4].itemList = this.createDictListRemoveCodes('2538',this.dealerTypeRemove);
            
          }
      });
      this.initFormBase[0].initialValue=this.value.rowData.appId.toUpperCase();
      //授权信息
      this.initFormEmpower.forEach(x => {
        x.initialValue = this.value.rowData[x.fieldName];
      });
      //建设节点信息
      this.initFormBuild.forEach(x => {
        // if(x.fieldName=="agreementOpenTime"||x.fieldName=="actualOpenTime"
        //       ||x.fieldName=="agreementFinishTime"||x.fieldName=="actualFinishTime"){
        //     x.initialValue =  parseTime(new Date(this.value.rowData[x.fieldName]),'{y}-{m}-{d} {h}:{i}:{s}');
        //   }else{
            x.initialValue =  this.value.rowData[x.fieldName];
          // }
      });

      //进度节点去掉操作列
      let columnActionIndexProgress = null;
      this.progressColumns.forEach((x,index) =>{
        if(x.dataIndex === 'column-action'){
          columnActionIndexProgress = index;
        }
      });
      if(columnActionIndexProgress != null){
        this.progressColumns.splice(columnActionIndexProgress,1);
      }
      //订购节点去掉操作列
      let columnActionIndexOrder = null;
      this.orderColumns.forEach((x,index) =>{
        if(x.dataIndex === 'column-action'){
          columnActionIndexOrder = index;
        }
      });
      if(columnActionIndexOrder != null){
        this.orderColumns.splice(columnActionIndexOrder,1);
      }
      //总部反馈去掉操作列
      let columnActionIndexFeedback = null;
      this.feedbackColumns.forEach((x,index) =>{
        if(x.dataIndex === 'column-action'){
          columnActionIndexFeedback = index;
        }
      });
      if(columnActionIndexFeedback != null){
        this.feedbackColumns.splice(columnActionIndexFeedback,1);
      }

      //执行进度节点信息查询
      this.doSearchDealerApplyPnode();
      
      //订购节点信息
      this.doSearchDealerApplyOnode();
      
      //总部反馈信息
      this.doSearchDealerApplyOemFeedback();

      //查询其他施工照片
      let resop = await searchOtherPhoto({},this.applyId);
      if (resop.resultCode === 200) {
          this.initFormFile.forEach(x => {
            let urlsList = resop.data.urls;
            if(urlsList!=null && urlsList.length>0){
              let fileList = [];
              for(let i in urlsList){
                  let fileName = { name: urlsList[i].fileName };
                  let fileId = { url: urlsList[i].fileId };
                  let f = Object.assign(fileName, fileId);
                  fileList.push(f);
              }
              x.initialValue = fileList;
            }
          });

      }else {
        this.$notify.error({title: '提示信息',message:'获取其他施工照片信息失败!'});
      }
      
    },
   

    //执行进度节点信息查询
    async doSearchDealerApplyPnode(){
      //进度节点信息
      let resp = await searchDealerApplyPnode({"currentPage":0,"pageSize":1000,"applyId":this.applyId});
      if (resp.resultCode === 200) {
        this.progressDataSource = [];
        this.progressDataSource = resp.data.records;
      }else {
        this.$notify.error({title: '提示信息',message:'获取进度节点信息失败!'});
      }
    },

    //订购节点信息
    async doSearchDealerApplyOnode(){
      let reso = await searchDealerApplyOnode({"currentPage":0,"pageSize":1000,"applyId":this.applyId});
      if (reso.resultCode === 200) {
        this.orderDataSource = [];
        this.orderDataSource = reso.data.records;
      }else {
        this.$notify.error({title: '提示信息',message:'获取订购节点信息失败!'});
      }
    },
    //总部反馈信息
    async doSearchDealerApplyOemFeedback(){
      let resf = await searchDealerApplyOemFeedback({"currentPage":0,"pageSize":2,"applyId":this.applyId});
      if (resf.resultCode === 200) {
        this.feedbackDataSource=[];
        this.feedbackDataSource=resf.data.records;
      }else {
        this.$notify.error({title: '提示信息',message:'获取总部反馈信息失败!'});
      }
    },


    //基本信息数据
    initFormBaseFun() {
      return [
         {//0
          type: 'INPUT',
          label: '品牌',
          fieldName: 'appId',
          placeholder: '',
          initialValue: '',
          disabled:true
        },
        {//1
          type: 'INPUT',
          label: '经销商简称',
          fieldName: 'dealerShortname',
          placeholder: '',
          initialValue: '',
          
        },
        {//2
          type: 'INPUT',
          label: '临时代码',
          fieldName: 'dealerCode',
          placeholder: '',
          initialValue: '系统自动生成',
          // readonly : true,
          disabled:true,
          
        },
        {//3
          type: 'INPUT',
          label: '公司全称',
          fieldName: 'dealerName',
          placeholder: '',
          initialValue: '',
          selfCols:3,
          
        },
        {//4
          type: 'SELECT',
          label: '渠道类型',
          fieldName: 'dealerType',
          placeholder: '',
          initialValue: '',
          itemList: this.createDictListRemoveCodes('2538',['25381004','25381005','25381006']),
          change: val => {
            this.changeDealerType(val);
          },
          
        },
        // {//5
        //   type: 'SELECT',
        //   label: '细分类型',
        //   fieldName: 'subType',
        //   placeholder: '',
        //   initialValue: '',
        //   itemList: this.createDictList('2539'),
          
        // },
        // { //5
        //   type: 'SELECT', 
        //   label: '细分类别', 
        //   fieldName: 'subType', 
        //   placeholder: '请选择', 
        //   initialValue: '', 
        //   hidden: !isArcfox() ,
        //   itemList: this.createDictList('2539'),
				// 		rules: isArcfox() ?[{required: true,message: '必填',trigger: 'change'}]:[]
				// },
        {//6
          type: 'SELECT',
          label: '经销商级别',
          fieldName: 'shopLevel',
          placeholder: '',
          initialValue: '',
          hidden:false,
          itemList: this.createDictList('2540'),
          
        },
        {//7
          type: 'SELECT',
          label: '事业部',
          fieldName: 'deptId',
          placeholder: '',
          initialValue: '',
          itemList: [],
          change: val => {
            this.changeDeptSelect(val);
          },
          
        },
        {//8
          type: 'SELECT',
          label: '办事处',
          fieldName: 'officeId',
          placeholder: '',
          initialValue: '',
          itemList: [],
          
        },
        {//9
          type: 'SELECT',
          label: '建设类型',
          fieldName: 'constructType',
          placeholder: '',
          initialValue: '',
          itemList: this.createDictList('2541'),
          
        },
        {//10
          type: 'SELECT',
          label: '省份',
          fieldName: 'provinceId',
          placeholder: '',
          initialValue: "",
          change: (value) => {
            this.initCity(value)
          },
          itemList:  [],
          
        },
        {//11
          type: 'SELECT',
          label: '城市',
          fieldName: 'cityId',
          placeholder: '',
          initialValue: "",
          itemList: [],
          change: (value) => {
            this.initTown(value)
          },
          
        },
        {//12
          type: 'SELECT',
          label: '县区',
          fieldName: 'districtId',
          placeholder: '',
          initialValue: "",
          itemList:  [],
          
        },
        {//22
          type: 'INPUT',
          label: '建设地址',
          fieldName: 'constructAddress',
          placeholder: '',
          initialValue: '',
          selfCols:3,
          
        },
        {//13
          type: 'INPUT',
          label: '店端主要联系人',
          fieldName: 'dealerLinkman',
          placeholder: '',
          initialValue: '',
          
        },
        {//14
          type: 'INPUT',
          label: '联系人电话',
          fieldName: 'dealerPhone',
          placeholder: '',
          initialValue: '',
          
        },
        {//15
          type: 'INPUT',
          label: '店端联系人邮箱',
          fieldName: 'dealerEmail',
          placeholder: '',
          initialValue: '',
          
        },
        {//16
          type: 'INPUT',
          label: '厂家负责人',
          fieldName: 'oemLinkman',
          placeholder: '',
          initialValue: '',
          
        },
        {//17
          type: 'INPUT',
          label: '负责人电话',
          fieldName: 'oemPhone',
          placeholder: '',
          initialValue: '',
          
        },
        { type: 'MULTIPLE_SELECT', 
          label: '体系内品牌', 
          fieldName: 'ownBrandCode', 
          placeholder: '', 
          initialValue: [], 
          itemList: this.createDictList('2545')
        },
        
        {//19
          type: 'INPUT',
          label: '项目设计师',
          fieldName: 'projectDesigner',
          placeholder: '',
          initialValue: '',
          
        },
        {//20
          type: 'INPUT',
          label: '设计师电话',
          fieldName: 'designerPhone',
          placeholder: '',
          initialValue: '',
          
        },
        {//18
          type: 'SELECT',
          label: '展厅级别',
          fieldName: 'salesLevel',
          placeholder: '',
          initialValue: '',
          hidden:false,
          itemList: this.createDictList('2542')
        },
        {//21
          type: 'SELECT',
          label: '售后级别',
          fieldName: 'serviceLevel',
          placeholder: '',
          initialValue: '',
          hidden:false,
          itemList: this.createDictList('2543')
        },

        {
          type: 'INPUT',
          label: '创建人',
          fieldName: 'createdByName',
          placeholder: '',
          initialValue: '',
          disabled:true,
        },
        {
          type: 'INPUT',
          label: '创建时间',
          fieldName: 'createdAt',
          placeholder: '',
          initialValue: '',
          disabled:true,
        },
        
        
      ];
    },
    //授权信息数据
    initFormEmpowerFun() {
      return [
         {
          type: 'SELECT',
          label: '是否边建边销',
          fieldName: 'isSaling',
          placeholder: '',
          initialValue: '',
          hidden:false,
          itemList: this.createDictList('1004'),
          
        },
        {
          type: 'SELECT',
          label: '是否边建边修',
          fieldName: 'isServicing',
          placeholder: '',
          initialValue: '',
          hidden:false,
          itemList: this.createDictList('1004'),
          
        },
        {
          type: 'INPUT',
          label: '临时工时',
          fieldName: 'tempLabour',
          placeholder: '',
          initialValue: '',
          hidden:false,
          precision:2
        }
        
      ];
    },
    //建设节点信息数据
    initFormBuildFun() {
      return [
        {
          type: 'DATE',
          label: '协议开工时间',
          fieldName: 'agreementOpenTime',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: '',
          style: { width: '100%' },
          
        },
        {
          type: 'DATE',
          label: '实际开工时间',
          fieldName: 'actualOpenTime',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: '',
          style: { width: '100%' },
          
        },
        {
          type: 'DATE',
          label: '协议完工时间',
          fieldName: 'agreementFinishTime',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: '',
          style: { width: '100%' },
          
        },
        {
          type: 'SELECT',
          label: '建设状态节点',
          fieldName: 'buildStatus',
          placeholder: '',
          initialValue: '',
          itemList: this.createDictList('2546'),
          
        },
        {
          type: 'INPUT',
          label: '总体建设进度',
          fieldName: 'buildProcess',
          initialValue: '',
          unitRender: () => {
            return <el-button slot="append">%</el-button>;
          },
          
        },
        {
          type: 'DATE',
          label: '实际完工时间',
          fieldName: 'actualFinishTime',
          style: { width: '100%' },
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '',
          placeholder: '',
          
        }
        
      ];
    },

    //进度节点列表表头
    creatHeaderProgress() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '进度节点类型',
          dataIndex: 'nodeType',
          sorter: true,
          render: props => {
            //编码转汉字
            return <span>{this.createDictText(props.row.nodeType, '2547')}</span>;
          }
        },
        { title: '时间', dataIndex: 'nodeTime', dateFormat:'yyyy-MM-dd',sorter: true },
        {
          title: '附件',
          dataIndex: 'urls',
          sorter: true,
          render: props => {
            let fileStr=[];
            for(let i in props.row.urls){
              fileStr.push(<a href={props.row.urls[i].fileId} style='color:blue' target="_blank">{props.row.urls[i].fileName}</a>);
                // fileStr.push(
                //   <el-popover
                //   width="140"
                //   trigger="click"
                //   >
                //   <el-image  style="width: 140px; height: 140px" 
                //    src={props.row.urls[i].fileId}  
                //    preview-src-list={[props.row.urls[i].fileId]} 
                //    onClick={() => this.imgLick(props.row.urls[i])}></el-image>
                //   <el-button slot="reference" type="text" >{props.row.urls[i].fileName}</el-button>
                // </el-popover>
                  
                //   );
            }
            return <span>{fileStr}</span>;
          }
        }
      ];
    },

    //订购节点列表表头
    creatHeaderOrder() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '订购节点类型', dataIndex: 'onodeType', sorter: true ,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.onodeType, '2548')}</span>;
        }},
        { title: '订购时间', dataIndex: 'orderTime',dateFormat:'yyyy-MM-dd', sorter: true },
        { title: '到货时间', dataIndex: 'arrivalTime',dateFormat:'yyyy-MM-dd', sorter: true},
        { title: '订购金额', dataIndex: 'orderFee',numberFormat:true,  sorter: true},
        { title: '安装时间', dataIndex: 'installTime',dateFormat:'yyyy-MM-dd', sorter: true}
      ];
    },
    //总部反馈列表表头
    creatHeaderFeedback () {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '执行反馈状态', dataIndex: 'feedbackStatus', sorter: true ,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.feedbackStatus, '2549')}</span>;
        }},
        { title: '周度', dataIndex: 'feedbackWeek', sorter: true ,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.feedbackWeek, '2576')}</span>;
        }},
        { title: '时间', dataIndex: 'feedbackTime',dateFormat:'yyyy-MM-dd', sorter: true},
        { title: '进度说明', dataIndex: 'processDesc', sorter: true},
        { title: '整改项目', dataIndex: 'reformItem', sorter: true}
      ];
    },
    //施工进度说明列表表头
    creatHeaderPhoto() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '项目', dataIndex: 'constructionNamePra', sorter: true },
        { title: '子项目', dataIndex: 'constructionName', sorter: true },
        { title: '附件', dataIndex: 'urls', 
          render: props => {
            let fileStr=[];
            for(let i in props.row.urls){
              fileStr.push(<a href={props.row.urls[i].fileId} style='color:blue' target="_blank">{props.row.urls[i].fileName}</a>);
                // fileStr.push(
                //   <el-popover
                //   width="140"
                //   trigger="click"
                //   >
                //   <el-image  style="width: 140px; height: 140px" 
                //    src={props.row.urls[i].fileId}  
                //    preview-src-list={[props.row.urls[i].fileId]} 
                //    onClick={() => this.imgLick(props.row.urls[i])}></el-image>
                //   <el-button slot="reference" type="text" >{props.row.urls[i].fileName}</el-button>
                // </el-popover>
                  
                //   );
            }
            return <span>{fileStr}</span>;
          }
        },
        { title: '上传日期', dataIndex: 'updatedAt', sorter: true,dateFormat:'yyyy-MM-dd', },
        { title: '审核结果', dataIndex: 'auditResult', sorter: true ,
           render: props => {    //编码转汉字
            return <span>{this.createDictText(props.row.auditResult, '2550')}</span>;
        }},
        { title: '审核说明', dataIndex: 'auditDesc',  sorter: true  }
      ];
    },
    //附件信息数据
    initFormFileFun() {
      return [
        {
          type: 'UPLOAD_FILE',
          label: '其他施工附件',
          fieldName: 'fileUrl',
          initialValue: '',
          upload: {
            limit:0,
            actionUrl: '/api/file/oss/upload'
          }
        }
      ];
    },
    //获取事业部下拉列表数据
    async getDeptData() {
      const res = await getRegion();
      if (res.resultCode === 200) {
        this.initFormBase.find(item => item.fieldName === 'deptId').itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
      }
    },
    
    //事业部下拉改变执行方法，级联查询该事业部下的办事处
    async changeDeptSelect(deptId,flag = true) {
      if(flag){
        this.initFormBase.find(item => item.fieldName === 'officeId').initialValue = '';
        this.initFormBase.find(item => item.fieldName === 'officeId').itemList = [];
      }
      if (!deptId) {
      } else {
        const res = await getCommunity(deptId);
        if (res.resultCode === 200) {
         this.initFormBase.find(item => item.fieldName === 'officeId').itemList = res.data.map(x => ({ value: parseInt(x.id), text: x.orgName }));
        }
      }
    },
    
    //初始化所在省份
    async initProvince(){
      let pl = this.createRegionList();
      this.initFormBase.find(item => item.fieldName === 'provinceId').itemList = pl;
      // this.initFormBase[19].itemList = pl;
    },
    //初始化所在市数据
    async initCity(provinceId,flag = true){
      if(flag){
        //清空市
        this.initFormBase.find(item => item.fieldName === 'cityId').initialValue="";
        this.initFormBase.find(item => item.fieldName === 'cityId').itemList = [];
        //清空县
        this.initFormBase.find(item => item.fieldName === 'districtId').initialValue="";
        this.initFormBase.find(item => item.fieldName === 'districtId').itemList=[];
      }

      if(!provinceId || provinceId==null || typeof(provinceId)=='undefined'){
        return;
      }
      //取省数据
      let rd = this.getRegionData();
      this.cityData = rd[provinceId].children;
      let cl = this.createSubRegionList(this.cityData);
      this.initFormBase.find(item => item.fieldName === 'cityId').itemList = cl;
    },
    //初始化所在县数据
    async initTown(cityId,flag = true){
      if(flag){
        //清空县
        this.initFormBase.find(item => item.fieldName === 'districtId').initialValue="";
        this.initFormBase.find(item => item.fieldName === 'districtId').itemList=[];
      }
      if(!cityId || cityId==null || typeof(cityId)=='undefined'){
        return;
      }
      let td = this.cityData[cityId].children;
      let tl = this.createSubRegionList(td);
      this.initFormBase.find(item => item.fieldName === 'districtId').itemList = tl;
    },
    //渠道类型切换
    changeDealerType(type,flag=true) {
      if (type) {
        //如果为4s店 展厅级别和售后级别都显示 经销商级别显示
        if(type === types.DEALER_TYPE_4S){
          this.$nextTick(() =>{
            if(flag){
              this.initFormBase.find(item => item.fieldName === 'salesLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'serviceLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'shopLevel').initialValue = undefined;
            }
            this.initFormBase.find(item => item.fieldName === 'salesLevel').hidden = false;
            this.initFormBase.find(item => item.fieldName === 'serviceLevel').hidden = false;
            this.initFormBase.find(item => item.fieldName === 'shopLevel').hidden = false;
          } )
          //是否边建边销和是否边建边修显示并必填
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').initialValue = '';
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').hidden = false;


        //如果为单一销售 展厅级别显示，售后级别隐藏  经销商级别显示
        }else if(type === types.DEALER_TYPE_SINGLE_SALE){
          this.$nextTick(() =>{
            if(flag){
              this.initFormBase.find(item => item.fieldName === 'salesLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'serviceLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'shopLevel').initialValue = undefined;
            }
            this.initFormBase.find(item => item.fieldName === 'salesLevel').hidden = false;
            this.initFormBase.find(item => item.fieldName === 'serviceLevel').hidden = true;
            this.initFormBase.find(item => item.fieldName === 'shopLevel').hidden = false;
          } )
          //是否边建边销显示并必填 ,是否边建边修不显示 临时工时不显示
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').hidden = true;
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').initialValue = '';
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').hidden = true;


        //如果为单一售后  售后级别显示，展厅级别隐藏 经销商级别显示
        }else if(type === types.DEALER_TYPE_SINGLE_AFTER){
          this.$nextTick(() =>{
            if(flag){
              this.initFormBase.find(item => item.fieldName === 'salesLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'serviceLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'shopLevel').initialValue = undefined;
            }
            this.initFormBase.find(item => item.fieldName === 'salesLevel').hidden = true;
            this.initFormBase.find(item => item.fieldName === 'serviceLevel').hidden = false;
            this.initFormBase.find(item => item.fieldName === 'shopLevel').hidden = false;
          } )
          //是否边建边销不显示 ,是否边建边修显示并必填
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').hidden = true;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').initialValue = '';
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').hidden = false;

        //如果为SPACE和RACE  经销商级别、展厅级别、售后级别字段不显示
        }else if(type === types.DEALER_TYPE_DIRECT_SHOP || type === types.DEALER_TYPE_NOT_DIRECT_SHOP){
          this.$nextTick(() =>{
            if(flag){
              this.initFormBase.find(item => item.fieldName === 'salesLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'serviceLevel').initialValue = undefined;
              this.initFormBase.find(item => item.fieldName === 'shopLevel').initialValue = undefined;
            }
            this.initFormBase.find(item => item.fieldName === 'salesLevel').hidden = true;
            this.initFormBase.find(item => item.fieldName === 'serviceLevel').hidden = true;
            this.initFormBase.find(item => item.fieldName === 'shopLevel').hidden = true;
          } )
          //边建边销要保留,是否边建边修、临时工时隐藏
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isSaling').hidden = false;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').initialValue = undefined;
          this.initFormEmpower.find(item => item.fieldName === 'isServicing').hidden = true;
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').initialValue = '';
          this.initFormEmpower.find(item => item.fieldName === 'tempLabour').hidden = true;

        }
      }
    },
    // 基础信息表单数据获取  
    formChangeHandleBase(data){
      this.formData.base = data;
    },
    // 授权信息表单数据获取  
    formChangeHandleEmpower(data){
      this.formData.empower = data;
    },
    //建设节点信息表单数据获取  
    formChangeHandleBuild(data){
      
    },

    //其他施工菜单
    formChangeHandleFile(data){
      this.formData = data;
    },
    //取消操作
    closeDialog(type) {
      this.$emit('close', { visible: false,type:type});
    },
    // 总部反馈 打开窗口 -传数据
    openFeed() {
      const pram = {
        applyId: this.applyId
      };
      this.initDataFeed=pram;
      this.visibleFeed = true;
    },
    // 总部反馈 关闭窗口 -返回数据
    closeFeed(data) {
      this.visibleFeed = data.visible; //关闭弹窗
    }
    
  }
};
</script>

<style lang="less" scoped>
</style>
